package problems;

import lib.MathLib;

public class Euler012 extends AbstractEuler {

	@Override
	public Number calculate() {
		for(long i = 1; i <= Long.MAX_VALUE; i++) {
			long triangleNumber = MathLib.getPolygonalNumber(i,3).longValue();
			long divisors = MathLib.getNumDivisors(triangleNumber);
			if (divisors > 500) return triangleNumber;
		}
		throw new IndexOutOfBoundsException("answer not found within range of Long");
	}

	@Override
	protected Number getCorrectAnswer() {
		return 76576500L;
	}

}
